package com.right.health.app.ui.household;

import android.os.Bundle;
import android.widget.TextView;

import com.magic.basic.activity.BaseActivity;
import com.right.health.app.R;
import com.right.health.app.widget.HealthSeekBar;

/*
 * 身高体重
 * Created by hopeliao on 2019-10-10
 *
 */
public class HeightWeightActivity extends BaseActivity implements HealthSeekBar.OnSeekBarChangeListener {

    private TextView mHeightValueTv, mWeightValueTv;

    private HealthSeekBar mHeightSeekBar, mWeightSeekBar;

    @Override
    public void onCreate(Bundle bundle, String s) {
        setContentView(R.layout.height_weight);
    }

    @Override
    public void findView() {
        mHeightValueTv = (TextView) findViewById(R.id.tv_height_value);
        mWeightValueTv = (TextView) findViewById(R.id.tv_weight_value);

        mHeightSeekBar = (HealthSeekBar) findViewById(R.id.height_seekbar);
        mHeightSeekBar.setTextIndex(160, 190);
        mHeightSeekBar.setOnSeekBarChangeListener(this);

        mWeightSeekBar = (HealthSeekBar) findViewById(R.id.weight_seekbar);
        mWeightSeekBar.setTextIndex(40, 90);
        mWeightSeekBar.setOnSeekBarChangeListener(this);
    }

    @Override
    public void initialize() {

    }

    @Override
    public void onProgressChanged(HealthSeekBar seekBar, float progress, boolean fromUser) {
        float value =seekBar.getMinValue() +  progress * (seekBar.getMaxValue() - seekBar.getMinValue());
        float text = (float) (Math.round(value * 10)) / 10;
        if(seekBar == mHeightSeekBar) {
            mHeightValueTv.setText(String.valueOf(text));
        } else if(seekBar == mWeightSeekBar) {
            mWeightValueTv.setText(String.valueOf(text));
        }
    }
}
